// pages/detailMovements/detailMovements.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
      detailMotions:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const selectMotion = wx.getStorageSync("selectMotion");
    //通过后台提取动作库
    const detailMotions = [
      {
        imgSrc: '/images/m_defualt.png',
        name: '曲臂杠铃上拉'
      },
      {
        imgSrc: '/images/m_defualt.png',
        name: '战绳猛扣'
      },
      {
        imgSrc: '/images/m_defualt.png',
        name: '战绳开合'
      },
      {
        imgSrc: '/images/m_defualt.png',
        name: '俯身T杠铃划船'
      }
    ];
    this.setData({
      detailMotions: detailMotions
    });
  },

  selectThis:function(e){
    const index = e.currentTarget.dataset.index;
    const detailMotion = this.data.detailMotions[index];
    const pages = getCurrentPages();
    const trainMovementPage = pages[pages.length-3];
    const selectMotions = trainMovementPage.data.selectMotions;
    selectMotions.push(detailMotion);
    trainMovementPage.setData({ selectMotions: selectMotions});
    wx.navigateBack({
      delta: 2
    });
  }
})